<%@ page language="java" pageEncoding="utf8"%>
<%@ page   import="daos.*"   %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<% Integer movieId = new Integer(request.getParameter("movieID")); 
boolean isLogin = (session.getAttribute("user") == null) ? false : true;%>
<% User u=(User)session.getAttribute("user"); %>
<jsp:include page="/head.jsp" />
<script type="text/javascript" src="script/movieInfo.js"></script>
<script type="text/javascript">
	Movie.movieId = <%=movieId%>;
	//Movie.movieId = '<%--=request.getParameter("movieID")--%>';
	//Movie.userId=document.getElementById("userId").value;
	//Movie.userId=1;
	Movie.userId='<%=u.getAddress()%>';
	Movie.commentsList = '<%=request.getAttribute("commentsResults")%>';
	dojo.addOnLoad( function(){
		document.getElementById("movieID").value = Movie.movieId;
   		Movie.askForMovieInfo();
   		Movie.askForMovieComments();
   	});
   	
   	function showAddCommentWindow(){
		dijit.byId("addCommentDlg").show();
	};
	function hideAddCommentWindow() {
		dijit.byId("addCommentDlg").hide();
	};
   	function addComment() {
   		var hasUser = "<%=isLogin%>";
   		//var hasUser="true"
   		if(hasUser == "true") {
   			showAddCommentWindow();
   		}
   		else {
   			window.location = "login.jsp";
   		}
   	};
   	function deleteCom(commentId,totalnum) {
		if(confirm("确认删除该评论？")==true) {
			var href = "deleteComment.do?commentId="+commentId;
			//用dom删除comment
			var min=totalnum-commentId;
			//alert(min);
			var elname= "comments_" + min ;
            var el = document.getElementById(elname);
			removeElement(el);
		    ajaxRequest(href,null);
		}
	};
	function viewMovieSession() {
		window.location.href = "movieSession.jsp?movieID="+<%=movieId%>
	}
	function removeElement(_element){
          var _parentElement = _element.parentNode;
          if(_parentElement){
           _parentElement.removeChild(_element);
         }
         }
</script>
<style type="text/css">
.starWrapper{border:1px solid #FFCC00;padding:5px;width:80px;}
.starWrapper img{cursor:pointer;}
</style>
<div class="maincontent">
	<div class="HackBox"></div>
	<div id="breadcrumb">
		&nbsp;
		<a href="index.jsp">主页</a>&nbsp;&gt;&nbsp;<a href="movieList.jsp">新片介绍</a>&nbsp;&gt;&nbsp;<span id="movie_name" style="color:red"></span>
	</div>
	<div class="maincontentin bookInfoMain">
		
		<div id="bookInfo">
			<table width="100%" id="bookInfoTable"> 
				<tr class="bookIntroduction"> 
					<td width="20%" class="bookImg"> 
						<img class="bookItemImg" id="bookImage" src=""/>
					</td> 
					<td width="55%"> 
						<div class="movieNameWrapper">
							<div class="movieName">
								<span id="movie_name"></span>
							</div>
						</div>
						<ul class="movieIntroInfo" style="padding-left:20px">
							<li class="listItem"> 
								<strong>导演：</strong><span id="directorName"></span> 
							</li>
							<li class="listItem"> 
								<strong>地区：</strong><span id="countryName"></span> 
							</li>
							<li class="listItem">
								<strong>编剧：</strong><span id="screenwriter"></span> 
							</li>
							<li class="listItem">
								<strong>摄影：</strong><span id="photographer"></span> 
							</li>
							<li class="listItem">
								<strong>主演：</strong><span id="actors"></span> 
							</li>
							<li class="listItem">
								<strong>上映：</strong><span id="shownTime"></span> 
							</li>
							<li class="listItem">
								<strong>类型：</strong><span id="type"></span> 
							</li>
							<li class="listItem">
								<strong>语言：</strong><span id="language"></span> 
							</li>
							<li class="listItem">
								<strong>时长：</strong><span id="time"></span> 
							</li>
						</ul> 
					</td> 
 				<td width="50%">
					<span class="blue-btn"> <span class="inputbtn">
					<span class="l"></span> <input type="button" value='查看电影场次' onclick="viewMovieSession()"></input>
				</td>

				</tr> 
				<tr> 
					<td colspan="3"> 
						<div class="dotted_line"></div> 
					</td> 
				</tr> 
				<tr class="introText"> 
					<td colspan="3"> 
						<div class="bookInfoTitle"> 
							剧情介绍 
						</div> 
						<div class="contentText" id="bookIntroText"> </div> 
					</td> 
				</tr> 
				<tr> 
					<td colspan="3"> 
						<div class="dotted_line"></div> 
					</td> 
				</tr>
				<tr> 
					<td colspan="3"> 
						<table class="commentTitle"> 
							<tr> 
								<td width="70%"> 
									<span class="movieInfoTitle">用户评论（共<span id="commentUserNum_2"></span>篇评论）</span> 
								</td> 
								<td> 
									<span class="orange-btn"><a href="#" onclick="addComment();"><span class="l"></span>添加评论</a> 
									</span> 
								</td> 
							</tr> 
						</table> 
						<div class="comments"> 
							<table width="80%" class="commentsTable"> 
								<tr class="commentItem" id="comments_0" style="display:none"> 
									<td class="userInfo"> 
										<a class="userImg" href="userInfo.html" id="picsrc_0"></a> 
									</td> 
									<td> 
										<div class="commentTitle"> 
											<span class="timeStamp" id="comment_timestamp_0">2008-04-08 13:32:37</span> 
                                            <span id="deletecom_0"></span>
										</div> 
										<div class="vote"> 
											<a class="userName" href="userInfo.html" id="username_0">owen</a> 对此电影评价： 
										</div> 
										<div class="commentContent"> 
											<span id="content_0">模式讲到如此的通俗易懂，真是感到很惊讶！初学者适用</span> 
										</div> 
									</td> 
								</tr>
								
								<tr class="commentItem" id="comments_1" style="display:none"> 
									<td class="userInfo"> 
										<a class="userImg" href="userInfo.html" id="picsrc_1"></a>
									</td> 
									<td> 
										<div class="commentTitle"> 
											<span class="timeStamp" id="comment_timestamp_1">2008-04-08 13:32:37</span><span id="deletecom_1"></span> 
										</div> 
										<div class="vote"> 
											<a class="userName" href="userInfo.html" id="username_1">owen</a> 对此电影评价：
										</div> 
										<div class="commentContent"> 
											<span id="content_1">模式讲到如此的通俗易懂，真是感到很惊讶！初学者适用</span> 
										</div> 
									</td> 
								</tr> 
 
								<tr class="commentItem" id="comments_2" style="display:none"> 
									<td class="userInfo"> 
										<a class="userImg" href="userInfo.html" id="picsrc_2"></a>
									</td> 
									<td> 
										<div class="commentTitle"> 
											<span class="timeStamp" id="comment_timestamp_2">2008-04-08 13:32:37</span><span id="deletecom_2"></span>
										</div> 
										<div class="vote"> 
											<a class="userName" href="userInfo.html" id="username_2">owen</a> 对此电影评价： 
											
										</div> 
										<div class="commentContent"> 
											<span id="content_2">模式讲到如此的通俗易懂，真是感到很惊讶！初学者适用</span> 
										</div> 
									</td> 
								</tr> 
								<tr class="commentItem" id="comments_3" style="display:none"> 
									<td class="userInfo"> 
										<a class="userImg" href="userInfo.html" id="picsrc_3"></a>
									</td> 
									<td> 
										<div class="commentTitle"> 
											<span class="timeStamp" id="comment_timestamp_3">2008-04-08 13:32:37</span><span id="deletecom_3"></span>
										</div> 
										<div class="vote"> 
											<a class="userName" href="userInfo.html" id="username_3">owen</a> 对此电影评价： 
									
										</div> 
										<div class="commentContent"> 
											<span id="content_3">模式讲到如此的通俗易懂，真是感到很惊讶！初学者适用</span> 
										</div> 
									</td> 
								</tr> 
								
								<tr class="commentItem" id="comments_4" style="display:none"> 
									<td class="userInfo"> 
										<a class="userImg" href="userInfo.html" id="picsrc_4"></a>
									</td> 
									<td> 
										<div class="commentTitle"> 
											<span class="timeStamp" id="comment_timestamp_4">2008-04-08 13:32:37</span><span id="deletecom_4"></span> 
										</div> 
										<div class="vote"> 
											<a class="userName" href="userInfo.html" id="username_4">owen</a> 对此电影评价： 
										
										</div> 
										<div class="commentContent"> 
											<span id="content_4">模式讲到如此的通俗易懂，真是感到很惊讶！初学者适用</span> 
										</div> 
									</td> 
								</tr>
							</table> 
						</div> 
 
					</td> 
				</tr>
			</table> 
 
		 		</div>

	</div>
	
	<div id="addCommentDlg"
		style="display: none;width:350px"
		dojoType="dijit.Dialog" title='添加评论' class="pop-window">
		<form action="addComment.do" method="post">
			<table>
			<input type="hidden" id="ratingValue" name="ratingValue" value="0">
			<input type="hidden" id="movieID" name="movieID" >
			<input type="hidden" id="userId" name="userId"  value="${user.userId}">
					<!-- <tr>
						<td width="25%">
						为书本评分
						</td>
						<td>
						 	<p class="starWrapper" onmouseover="rate(this,event)">
							<img id="rating_img_0" src="images/icon-rate-empty.gif" title="很烂" /><img id="rating_img_1" src="images/icon-rate-empty.gif" title="一般" /><img id="rating_img_2" src="images/icon-rate-empty.gif" title="还好" /><img id="rating_img_3" src="images/icon-rate-empty.gif" title="较好" /><img id="rating_img_4" src="images/icon-rate-empty.gif" title="很好" />
							
		                    </p>
						
					</tr></td>
					<tr>
						<td>
						标题
						</td>
						<td>
							<input dojoType="dijit.form.ValidationTextBox" id="subject"
								name='subject' required="true" invalidMessage="请输入评论标题" />
						</td>
					</tr>-->
					<tr>
						<td style="text-align:center">
						内容
						</td>
						<td>
							<div style="margin-top: 10px; width: 100%">
								<textarea id="content" name="content"
									dojoType="dijit.form.SimpleTextarea" rows=4 cols=90
									style="width: 100%;"></textarea>
							</div>
						</td>
					</tr>
					<tr>
						<td>
						<div style="margin-top: 15px; width: 100%; text-align:center">
						<button dojoType="dijit.form.Button" type="submit" style="margin-right:40px; margin-left:40px">
							确认
						</button>
						</div>
						</td>
						<td>
						<div style="margin-top: 15px; width: 100%; text-align:center">
						<button dojoType="dijit.form.Button" onclick="hideAddCommentWindow();">
							取消
						</button>
						</div>
						</td>
					</tr>
			</table>
		</form>
	</div>		
	<!-- main content -->

</div>

<jsp:include page="footer.jsp" />